import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/Login'
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import My from '@/views/My'
import Detail from '@/views/Detail'
import UserEdit from '@/views/My/user-edit'
import Search from '@/views/Search'
import SearchResult from '@/views/Search/SearchResult'
Vue.use(VueRouter)

// 配置路由path和component对应关系
const routes = [
  {
    path: '/login',
    component: Login
  },
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '', // 当一个二级路由的path是空字符串的时候 它作为一个默认的二级路由展示
        component: Home
      },
      {
        path: 'my',
        component: My
      },
      {
        path: 'search',
        component: Search
      }
    ]
  },
  {
    path: '/detail',
    component: Detail
  },
  {
    path: '/userEdit',
    component: UserEdit
  },
  {
    path: '/searchResult',
    component: SearchResult
  }
]

const router = new VueRouter({
  routes
})

export default router
